<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>303北 实验室</title>
  <link rel="stylesheet" href="../src/css/layui.css">
</head>
<body>

<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo layui-hide-xs layui-bg-black"><a style="color: white" href="javascript:home();">303北 实验室</a></div>
    <!-- 头部区域（可配合layui 已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <!-- 移动端显示 -->
      <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
        <i class="layui-icon layui-icon-spread-left"></i>
      </li>

      <li class="layui-nav-item layui-hide-xs"><a href="javascript:loginOut();">退出登录</a></li>
      <!--<li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>-->
      <!--<li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>-->

      <!--<li class="layui-nav-item">-->
      <!--<a href="javascript:;">nav groups</a>-->
      <!--<dl class="layui-nav-child">-->
      <!--<dd><a href="">menu 11</a></dd>-->
      <!--<dd><a href="">menu 22</a></dd>-->
      <!--<dd><a href="">menu 33</a></dd>-->
      <!--</dl>-->
      <!--</li>-->


    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide layui-show-md-inline-block">
        <a href="javascript:;">
          <img src="./img/303.jpg" class="layui-nav-img">
          <span id="rootname">未登录</span>
        </a>
        <dl class="layui-nav-child">
          <dd><a>账号</a><input id="username" type="text" name="username"></dd>
          <dd><a>密码</a><input id="password" type="text" name="password"></dd>
          <dd><a style="text-align:center;" href="javascript:update_user_and_pwd();">保存修改</a></dd>
        </dl>
      </li>

      <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
        <a href="javascript:;">
          <i class="layui-icon layui-icon-more-vertical"></i>
        </a>
      </li>
    </ul>
  </div>

  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="test">
        <!--<li class="layui-nav-item layui-nav-itemed">-->
        <!--<a class="" href="javascript:;">menu group 1</a>-->
        <!--<dl class="layui-nav-child">-->
        <!--<dd><a href="javascript:;">menu 1</a></dd>-->
        <!--<dd><a href="javascript:;">menu 2</a></dd>-->
        <!--<dd><a href="javascript:;">menu 3</a></dd>-->
        <!--<dd><a href="">the links</a></dd>-->
        <!--</dl>-->
        <!--</li>-->
        <!--<li class="layui-nav-item">-->
        <!--<a href="javascript:;">menu group 2</a>-->
        <!--<dl class="layui-nav-child">-->
        <!--<dd><a href="javascript:;">list 1</a></dd>-->
        <!--<dd><a href="javascript:;">list 2</a></dd>-->
        <!--<dd><a href="">超链接</a></dd>-->
        <!--</dl>-->
        <!--</li>-->
          <li id="student_info" class="layui-nav-item"><a href="javascript:student_info();">所有学生信息</a></li>
          <li id="student_find" class="layui-nav-item"><a href="javascript:student_find();">学生查找</a></li>
          <li class="layui-nav-item"><a href="javascript:device_info();">查看所有设备</a></li>
          <li class="layui-nav-item"><a href="javascript:device_find();">设备查找</a></li>
          <li class="layui-nav-item"><a href="javascript:add_device();">上传设备</a></li>
          <li class="layui-nav-item"><a href="javascript:data_info();">查看所有文章</a></li>
          <li class="layui-nav-item"><a href="javascript:data_find();">文章查找</a></li>
          <li class="layui-nav-item"><a href="javascript:add_data();">撰写文章</a></li>
          <li class="layui-nav-item"><a href="javascript:big_data_info();">查看所有文件</a></li>
          <li class="layui-nav-item"><a href="javascript:big_data_find();">文件查找</a></li>
          <li class="layui-nav-item"><a href="javascript:add_big_data();">上传文件</a></li>
          <li id="register_request_info" class="layui-nav-item"><a href="javascript:register_request_info();">学生注册申请</a></li>
		  <li id="add_teacher" class="layui-nav-item"><a href="javascript:add_teacher();">添加老师</a></li>
      </ul>
    </div>
  </div>

  <div class="layui-body">
    <!-- 内容主体区域 -->
    <iframe id="frame" style="width: 100%;height: 100%" src="../../welcome.jpg">
      <p>浏览器不支持  iframe 标签</p>
    </iframe>


    <div class="layui-footer">
      &copy bitterteaer
    </div>
  </div>
</div>

<script src="../src/layui.js"></script>
<script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            // ,menuRight: function(){
                // layer.open({
                //     type: 1
                //     ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                //     ,area: ['260px', '100%']
                //     ,offset: 'rt' //右上角
                //     ,anim: 5
                //     ,shadeClose: true
                // });
            // }
        });

    });
</script>
<script src="../../js/JQ.js"></script>
<script>
    $.post(
        "/user/user_data_is_login",
        {},
        function (data,states) {
            console.log(data);
            if(data == "error"){
                window.location.href="/";
                return;
            }
            //console.log(typeof data);
            //var json = JSON.parse(String(data));
            document.getElementById("rootname").innerHTML=data.name;
            document.getElementById("username").value=data.username;
            document.getElementById("password").value=data.password;

            //console.log(typeof data.power)

            if(data.power > 1){
                document.getElementById("student_info").style.display = "none";
                document.getElementById("student_find").style.display = "none";
                document.getElementById("register_request_info").style.display = "none";
            }
            if(data.power > 0){
                document.getElementById("add_teacher").style.display = "none";
            }
        }
    );
    function device_info() {
        document.getElementById("frame").src="../../device_info.html";
    }
    function device_find() {
        document.getElementById("frame").src="../../device_find.html";
    }
    function student_info() {
        document.getElementById("frame").src="../../student_info.html";
    }
    function student_find() {
        document.getElementById("frame").src="../../student_find.html";
    }
    function add_data() {
        document.getElementById("frame").src="../../add_data.html";
    }
    function add_device() {
        document.getElementById("frame").src="../../layuimini-2/page/add_device.html";
    }
    function data_find() {
        document.getElementById("frame").src="../../data_find.html";
    }
    function data_info() {
        document.getElementById("frame").src="../../data_info.html";
    }
    function register_request_info() {
        document.getElementById("frame").src="../../register_requests_info.html";
    }
	function home() {
        // window.location.reload();
	    document.getElementById("frame").src="../../image/welcome.jpg";
	}
	function loginOut() {
        $.post(
            "/user/login_out",
            {},
            function (data,states) {
                window.location.href="/"
            }
        );
    }
    function add_big_data() {
	    document.getElementById("frame").src="../../add_big_data.html";
    }
    function update_user_and_pwd() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        $.post(
            "/user/update_user_and_pwd",
            {
                "username":username,
                "password":password
            },
            function (data,states) {
                alert(data);
            }
        );
    }
	function add_teacher(){
	    document.getElementById("frame").src="../../add_teacher.html";
	}
	function big_data_info() {
        document.getElementById("frame").src="../../big_data_info.html";
    }
    function big_data_find() {
        document.getElementById("frame").src="../../big_data_find.html";
    }
    /*
    $.post(
        "/GetUserData",
        {
            "page":1,
            "limit":4
        },
        function (data,states) {
            console.log(data);
        }
    );*/
</script>
</body>
</html>
